import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'amfe-flexible'
Vue.config.productionTip = false
import {
  NavBar,
  Form,
  Field,
  Button,
  Tabbar,
  TabbarItem,
  Icon,
  Tab,
  Tabs,
  Cell,
  List,
  PullRefresh,
  ActionSheet,
  Popup,
  Tag,
  Badge,
  Search,
  Image as VanImage,
  Divider,
  ShareSheet,
  CellGroup,
  Dialog,
  DatetimePicker
} from 'vant'
Vue.use(DatetimePicker);
Vue.use(Dialog);
Vue.use(CellGroup);
Vue.use(ShareSheet);
Vue.use(Divider);
Vue.use(VanImage);
Vue.use(Search);
Vue.use(Badge);
Vue.use(Tag);
Vue.use(Popup);
Vue.use(ActionSheet);
Vue.use(PullRefresh);
Vue.use(List);
Vue.use(Cell);
Vue.use(Tab);
Vue.use(Tabs);
Vue.use(Icon);
Vue.use(Tabbar)
Vue.use(TabbarItem)
Vue.use(Button)
Vue.use(Form)
Vue.use(Field)
Vue.use(NavBar)
// 封装一个自动聚焦插件
let focusObj={
  install(Vue){
    Vue.directive('focus',{
      inserted(el){
        if(el.nodeName==='TEXTAREA'||el.nodeName==='INPUT'){
          el.focus()
        }else{
          let ipt=el.querySelector('input')
          let txt=el.querySelector('textarea')
          if(ipt) ipt.focus()
          if(txt) txt.focus()
        }
      },
      update(el) {
        if(el.nodeName==='TEXTAREA'||el.nodeName==='INPUT'){
          el.focus()
        }else{
          let ipt=el.querySelector('input')
          let txt=el.querySelector('textarea')
          if(ipt) ipt.focus()
          if(txt) txt.focus()
        }
      },
    })
  }
}

Vue.use(focusObj)
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
